package com.ztesoft.web.baseconfig.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.framework.log.ZTEsoftLogManager;
import com.ztesoft.web.baseconfig.service.IDmFilePlanService;
import com.ztesoft.web.baseconfig.vo.DmFilePlanVO;
import com.ztesoft.web.common.vo.DmHostConnInfoVO;

/**
 * <Description>文件计划管理 <br>
 * 
 * @author lin.jie <br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2016年5月25日 <br>
 * @since V1.0<br>
 * @see com.ztesoft.web.baseconfig.controller <br>
 */

@Controller
@RequestMapping("/baseconfig/dmfileplan")
public class DmFilePlanController {

	private static final ZTEsoftLogManager logger = ZTEsoftLogManager.getLogger(DmFilePlanController.class);

	@Autowired
	private IDmFilePlanService dmPlanFileService;

	@RequestMapping("index")
	@ResponseBody
	public ModelAndView index(Model model) {
		ModelAndView view = new ModelAndView("index");
		view.addObject("moduleMainView", "planmanage/addfileplan/views/AddFilePlan");
		return view;
	}

	/**
	 * 源/目标主机配置数据源
	 * 
	 * @return
	 * @throws BaseAppException
	 */
	@RequestMapping("getHostInfo")
	@ResponseBody
	public List<DmHostConnInfoVO> getHostInfo() throws BaseAppException {
		return dmPlanFileService.getHostInfo();
	}

	/**
	 * 判断计划名称是否重复
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("planNameIsRepeated")
	@ResponseBody
	public boolean planNameIsRepeated(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.planNameIsRepeated(record);
	}
	
	/**
	 * 判断策略名称是否重复
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("strategyNameIsRepeated")
	@ResponseBody
	public boolean strategyNameIsRepeated(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.strategyNameIsRepeated(record);
	}

	/**
	 * 提交计划-文件-所有信息-包括源和目标
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("addAllInfo")
	@ResponseBody
	public DmFilePlanVO addAllInfo(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.addAllInfo(record);
	}
	
	/**
	 * 获取 计划-文件-的信息
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("getPlanInfo")
	@ResponseBody
	public DmFilePlanVO getPlanInfo(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.getPlanInfo(record);
	}
	
	/**
	 * 获取 计划-文件-策略的信息
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("getStrategyInfo")
	@ResponseBody
	public DmFilePlanVO getStrategyInfo(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.getStrategyInfo(record);
	}
	
	/**
	 * 获取 计划-文件-目录表达式验证
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("xpathVerify")
	@ResponseBody
	public DmFilePlanVO xpathVerify(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.xpathVerify(record);
	}
	
	/**
	 * 获取 计划-文件-文件名匹配规则验证
	 * 
	 * @param record
	 * @return record
	 * @throws BaseAppException
	 */
	@RequestMapping("fileNameVerify")
	@ResponseBody
	public DmFilePlanVO fileNameVerify(DmFilePlanVO record) throws BaseAppException {
		return dmPlanFileService.fileNameVerify(record);
	}
}
